//2. 下面的程序根据出行天数估算旅行的费用。设计一个抽象类TravelMethod，它包含两个抽象方法：
//(1）showTravelInfo()用于显示旅行的相关信息；
//(2）calculatePrice()用于计算旅行费用。
//自驾游类SelfDrivingTravel继承自TravelMethod类。本程序实现计算小轿车自驾7天游的费用，程序的运行结果如下图所示，请将程序补充完整。

public class TC2 {
    public static void main(String[] args) {
        TravelMethod travelMethod = new SelfDrivingTravel(7,1);//小轿车自驾7天游
        travelMethod.showTravelInfo();
        System.out.println("旅行费用："+travelMethod.calculatePrice()+"元");
    }
}
abstract class TravelMethod {
    protected int days;
    public TravelMethod(int days){
        this.days = days;
    }
    public abstract void  showTravelInfo();
    public abstract double calculatePrice();
}

class SelfDrivingTravel extends TravelMethod{
    private int carType;
    public SelfDrivingTravel(int days,int carType){
        super(days);
        this.carType = carType;
    }
    public void showTravelInfo(){
        System.out.println("出行方式：自驾游");
        System.out.println("出行天数："+days);
        System.out.println("车型："+(carType==1?"小轿车":"越野车"));
    }
    public double calculatePrice(){
        double basePrice = carType ==1?500.0:800.0;
        double pricePerDay = carType ==1?50.0:80.0;
        return basePrice + days*pricePerDay;
    }
}
